﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    public class DB
    {
       static string Str = ConfigurationManager.AppSettings["wwj"];
        /// <summary>
        /// 返回getTable集合
        /// </summary>
        /// <param name="sql">sring类型的Sql语句</param>
        /// <returns></returns>
        public static DataTable GetTable(string sql) {
            SqlDataAdapter adt = new SqlDataAdapter(sql,Str);
            DataTable dat = new DataTable();
            adt.Fill(dat);
            return dat;
        }
        /// <summary>
        /// 执行增删该操作
        /// </summary>
        /// <param name="sql">返回bool类型</param>
        /// <returns></returns>
        public bool ZSG(string sql) {
            SqlConnection conn = new SqlConnection(Str);
            conn.Open();
            SqlCommand com = new SqlCommand(sql,conn);
            int result = com.ExecuteNonQuery();
            conn.Close();
            return result > 0;
        }
    }
}
